<template>
  <base-panel>
    <top-simple-search @searchFun="query" @addFun="toAdd">
      <el-form-item label="" >
        <el-input placeholder="审批人" v-model="searchParams.participant" size="small" style="width: 200px;" clearable></el-input>
      </el-form-item>
      <el-form-item label="" >
        <el-date-picker
          v-model="selectDate"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          size="small"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="" >
        <dept-select-tree v-model="searchParams.workflow" :disable-branch-nodes="true" placeholder="请选择工作流"  v-bind="$attrs" dept-type="other" :all-dept-list="workflowsList" v-if="loading" style="width: 200px;" size="small"></dept-select-tree>
      </el-form-item>
    </top-simple-search>
    <simple-table ref="myTable" size="mini">
      <my-table-column label="工作流名称" align="center" prop="work_name"/>
      <my-table-column label="标题" align="center"  prop="title" min-width="200"></my-table-column>
      <my-time-column label="审批时间" align="center" prop="gmt_created" width="180"/>
      <my-table-column label="审批人" align="center" prop="creator_name"></my-table-column>
      <my-table-column label="审批意见" align="center" prop="suggestion" min-width="200"></my-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120" fixed="right">
        <template slot-scope="{row}">
          <edit-button @click="toEdit(row)"></edit-button>
          <delete-button @click="toDelete(row.id)"></delete-button>
        </template>
      </el-table-column>
    </simple-table>
    <edit-dialog  :visible.sync="visible" v-if="visible" :row="currRow" @reloadList="getList"></edit-dialog>
  </base-panel>
</template>
<script>
  import simpleTable from '@/mixins/SimpleTable'
  import MyTimeColumn from '@/components/TableColumn/MyTimeColumn'
  import MySwitchColumn from '@/components/TableColumn/MySwitchColumn'
  import MyDictColumn from '@/components/TableColumn/MyDictColumn'
  import MyTableColumn from '../../../../components/TableColumn/MyTableColumn'
  import EditDialog from '../../../../components/WorkFlowsDialog/DocumentCase/EditDialog'
  import common from "@/api/common/index"
  import DeptSelectTree from '@/components/Common/DeptSelectTree'
  // 获取登录用户信息
  export default {
    name:"userTable",
    components: { DeptSelectTree, EditDialog, MyTableColumn, MyDictColumn, MySwitchColumn, MyTimeColumn },
    mixins: [simpleTable],
    data() {
      return {
        interveneVisible: false,
        searchParams:{starttime:"",endtime:"",search_value:"",participant:undefined,workflow:undefined},
        selectDate:[],
        workflowsList:[],
        loading:false
      }
    },
    created() {
      this.getWorkflowsSimple()
    },
    methods: {
      showInterveneDialog(row){
        this.currRow = row
        this.interveneVisible = true
      },
      query(queryData) {
        this.searchParams.search_value = queryData
        if(this.selectDate){
          this.searchParams.starttime = this.selectDate[0]
          this.searchParams.endtime = this.selectDate[1]
        }else{
          this.searchParams.starttime = ""
          this.searchParams.endtime = ""
        }
        this.$refs["myTable"].searchList(this.searchParams);
      },
      getWorkflowsSimple(){
        common.getWorkflowsSimple().then(res=>{
          this.workflowsList = res.data;
          this.loading = true
        })
      },
    }
  }
</script>
